//! 程序员字符集专项演示

use unichar::{Unichar, Config, Style};

fn main() {
    println!("=== 程序员字符集专项演示 ===\n");

    let mut unichar = Unichar::new();
    unichar.set_config(Config::new().with_style(Style::Icon));

    // 1. Git 工作流
    println!("1. 🔀 Git 工作流:");
    let git_workflow = [
        "git", "commit", "branch", "merge", "pull_request", 
        "push", "pull", "fork", "clone"
    ];
    for char_name in git_workflow {
        if let Some(char) = unichar.get(char_name) {
            print!("{} ", char);
        }
    }
    println!("\n");

    // 2. 编程语言相关
    println!("2. 💻 编程语言相关:");
    let programming = [
        "code", "function", "class", "variable", "constant",
        "array", "string", "number", "boolean", "object"
    ];
    for char_name in programming {
        if let Some(char) = unichar.get(char_name) {
            print!("{} ", char);
        }
    }
    println!("\n");

    // 3. 调试和错误处理
    println!("3. 🐛 调试和错误处理:");
    let debugging = [
        "bug", "debug", "error_log", "warning_log", "info_log",
        "debug_log", "test", "unit_test", "integration_test"
    ];
    for char_name in debugging {
        if let Some(char) = unichar.get(char_name) {
            print!("{} ", char);
        }
    }
    println!("\n");

    // 4. 开发流程
    println!("4. 🚀 开发流程:");
    let development = [
        "feature", "enhancement", "refactor", "hotfix", "patch",
        "release", "deploy", "build", "compile"
    ];
    for char_name in development {
        if let Some(char) = unichar.get(char_name) {
            print!("{} ", char);
        }
    }
    println!("\n");

    // 5. 性能监控
    println!("5. ⚡ 性能监控:");
    let performance = [
        "performance", "speed", "memory", "cpu", "disk",
        "network", "metrics", "monitoring", "alert"
    ];
    for char_name in performance {
        if let Some(char) = unichar.get(char_name) {
            print!("{} ", char);
        }
    }
    println!("\n");

    // 6. 数据库相关
    println!("6. 🗄️ 数据库相关:");
    let database = [
        "database", "table", "query", "sql", "nosql",
        "data", "storage", "backup", "replication"
    ];
    for char_name in database {
        if let Some(char) = unichar.get(char_name) {
            print!("{} ", char);
        }
    }
    println!("\n");

    // 7. 服务器和API
    println!("7. 🔌 服务器和API:");
    let server = [
        "server", "api", "endpoint", "rest", "graphql",
        "microservice", "load_balancer", "gateway"
    ];
    for char_name in server {
        if let Some(char) = unichar.get(char_name) {
            print!("{} ", char);
        }
    }
    println!("\n");

    // 8. 容器化
    println!("8. 📦 容器化:");
    let container = [
        "container", "docker", "kubernetes", "k8s",
        "orchestration", "deployment", "service"
    ];
    for char_name in container {
        if let Some(char) = unichar.get(char_name) {
            print!("{} ", char);
        }
    }
    println!("\n");

    // 9. 云服务
    println!("9. ☁️ 云服务:");
    let cloud = [
        "cloud_compute", "aws", "azure", "gcp",
        "serverless", "lambda", "cdn", "storage"
    ];
    for char_name in cloud {
        if let Some(char) = unichar.get(char_name) {
            print!("{} ", char);
        }
    }
    println!("\n");

    // 10. 安全相关
    println!("10. 🔒 安全相关:");
    let security = [
        "security", "encryption", "auth", "authentication",
        "authorization", "permission", "ssl", "firewall"
    ];
    for char_name in security {
        if let Some(char) = unichar.get(char_name) {
            print!("{} ", char);
        }
    }
    println!("\n");

    // 11. 开发工具
    println!("11. 🔧 开发工具:");
    let tools = [
        "tool", "ide", "editor", "terminal", "command",
        "cli", "debugger", "profiler", "version_control"
    ];
    for char_name in tools {
        if let Some(char) = unichar.get(char_name) {
            print!("{} ", char);
        }
    }
    println!("\n");

    // 演示编程场景的字符串格式化
    println!("📝 编程场景字符串格式化演示:");
    unichar.set_config(Config::new().with_style(Style::Icon));
    
    let programming_scenarios = [
        "Git操作: {git} -> {commit} -> {push}",
        "调试流程: 发现{bug} -> 运行{test} -> 修复{bug}",
        "部署流程: {build} -> {test} -> {deploy}",
        "性能优化: 监控{performance} -> 分析{metrics} -> 优化{speed}",
        "安全检查: {security} -> {auth} -> {encryption}",
        "容器部署: {docker} -> {kubernetes} -> {deploy}",
        "API开发: 设计{api} -> 实现{endpoint} -> 测试{test}",
        "数据库: 设计{database} -> 编写{sql} -> 优化{performance}",
    ];
    
    for scenario in programming_scenarios {
        let result = unichar.format(scenario);
        println!("   {}", result);
    }
    println!();

    // 演示不同样式的切换
    println!("🎨 程序员字符样式切换演示:");
    let programmer_chars = ["code", "bug", "deploy", "database"];
    
    for style in [Style::Simple, Style::Icon, Style::Bold] {
        unichar.set_config(Config::new().with_style(style.clone()));
        print!("{:?}: ", style);
        for char_name in programmer_chars {
            if let Some(char) = unichar.get(char_name) {
                print!("{} ", char);
            }
        }
        println!();
    }
    println!();

    // 显示程序员相关字符的统计
    println!("📊 程序员字符集统计:");
    let programmer_related = [
        "code", "function", "class", "variable", "bug", "test", "deploy",
        "git", "commit", "database", "api", "server", "docker", "security"
    ];
    
    let mut found_count = 0;
    for char_name in programmer_related {
        if unichar.has_character(char_name) {
            found_count += 1;
        }
    }
    
    println!("   测试的{}个程序员相关字符中，找到{}个", programmer_related.len(), found_count);
    println!("   覆盖率: {:.1}%", (found_count as f64 / programmer_related.len() as f64) * 100.0);
    
    println!("\n🎉 程序员字符集演示完成！");
}
